package org.baicaix.demo.loader {
	import flash.net.URLLoaderDataFormat;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	/**
	 * @author dengyang
	 * @date 2010-4-22
	 */
	public class LoaderDemo extends Sprite {
		
		private var loader : URLLoader;
		
		public function LoaderDemo() {
			//文本、二进制、参数的读取
			loader = new URLLoader();
			loader.dataFormat = URLLoaderDataFormat.BINARY;
			loader.addEventListener(Event.COMPLETE, loadCompleteHandler);
			
			var request : URLRequest = new URLRequest("img/img.jpg");
			loader.load(request);
		}

		private function loadCompleteHandler(event : Event) : void {
			var loader : Loader = new Loader();
			var urlloader : URLLoader = event.target as URLLoader;
			
			//ByteArray转显示对象
			loader.loadBytes(urlloader.data);
			this.addChild(loader);
		}
	}
}
